﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.windows.sun.sunWindow {
    import flash.events.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.events.windows.*;
    import net.wooga.pets.constants.*;
    import net.wooga.pets.views.windows.restricted.*;
    import net.wooga.pets.constants.windows.*;

    public class SunNotificationWindowMediator extends BaseWindowMediator {

        public var tutorialModel:TutorialModel;

        override public function preRegister():void{
            super.preRegister();
            eventMap.mapListener(eventDispatcher, WindowsMainViewUpdateEvent.REMOVE_SUN_WINDOW, super.onWindowRemoveRequest, WindowsMainViewUpdateEvent);
            eventMap.mapListener(eventDispatcher, GameConstants.SUN_HIDE_BUBBLE, this.hideMainView);
            eventMap.mapListener(eventDispatcher, GameConstants.SUN_SHOW_BUBBLE, this.showMainView);
            eventMap.mapListener(eventDispatcher, WindowsMainViewUpdateEvent.REMOVE_ALL_SUN_WINDOWS, this.onClearAllWindowsEventReceived);
        }
        override protected function viewAddedToDisplayList(_arg1:Event):void{
            if ((((this.tutorialModel.state < TutorialModel.END)) && (!((this.tutorialModel.state == TutorialModel.FOUNTAIN_CLICK_ON_ELDER))))){
                SunNotificationWindow(window).mouseEnabled = false;
            };
            super.viewAddedToDisplayList(_arg1);
        }
        private function onClearAllWindowsEventReceived(_arg1:WindowsMainViewUpdateEvent):void{
            eventMap.unmapListener(eventDispatcher, WindowsMainViewUpdateEvent.REMOVE_ALL_SUN_WINDOWS, this.onClearAllWindowsEventReceived);
            this.onClosing();
        }
        private function showMainView(_arg1:InfoEvent):void{
            this.windowAsSprite.visible = true;
        }
        private function hideMainView(_arg1:InfoEvent):void{
            this.windowAsSprite.visible = false;
        }
        override protected function notifiyMediatorAddedToDisplay():void{
            this.dispatch(new Event(WindowsEventConstants.NOTIFICATION_VIEW_ADDED_TO_STAGE));
        }
        override protected function notifiyMediatorRemovedToDisplay():void{
            this.dispatch(new Event(WindowsEventConstants.NOTIFICATION_VIEW_REMOVED_FROM_STAGE));
        }
        override protected function onClosing():void{
            super.onClosing();
            var _local1:WindowCommandTriggerEvent = new WindowCommandTriggerEvent(WindowCommandTriggerEvent.DESTROY_SUN_WINDOW);
            _local1.window = window;
            dispatch(_local1);
        }

    }
}//package net.wooga.pets.views.windows.sun.sunWindow 
